//
//  UIApplication+ZTHook.m
//  APPDemo
//
//  Created by 郭红旗 on 2021/10/14.
//

#import "UIApplication+ZTTXHook.h"
#import <objc/runtime.h>
#import "NSObject+MethodSwizzling.h"
#import "ZTTXAutoTrackUtils.h"

@implementation UIApplication (ZTTXHook)

+ (void)hookUIApplication
{
    [UIApplication lbp_swizzleMethod: @selector(sendAction:to:from:forEvent:) swizzledSelector: @selector(hook_sendAction:to:from:forEvent:)];

}

- (BOOL)hook_sendAction:(SEL)action to:(nullable id)target from:(nullable id)sender forEvent:(nullable UIEvent *)event;
{
//    NSString *actionDetailInfo = [NSString stringWithFormat:@"click_widget %@ - %@ - %@", NSStringFromClass([target class]), NSStringFromClass([sender class]), NSStringFromSelector(action)];
    NSMutableDictionary *dic =  [ZTTXAutoTrackUtils propertiesWithAutoTrackObject:(UIView *)sender viewController:nil];
    NSLog(@"%@", dic);

    return [self hook_sendAction:action to:target from:sender forEvent:event];
}

@end
